<!--
 * @Description: 
 * @Version: 1.0
 * @Autor: YuanJun
 * @Date: 2020-05-24 01:04:41
 * @LastEditors: YuanJun
 * @LastEditTime: 2020-05-24 10:20:06
--> 

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Index</title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.min.js"></script>

<style>
  body{
    width: 100%;
    height: 100%;
    background: #c5cbee;
  }
  .box{
    width: 50%;
    height: 48px;
    text-align: center;
    margin: 188px auto;
    font-size: 32px;
    font-weight: 500;
    color: #6978cc;
  }
</style>




</head>
<body>
  <div class="box">
      <a id="email"></a> 欢迎登陆系统！
  </div>
</body>
</html>
<script type="text/javascript">
$(function(){

	$('#email').text('email');
  let token = getCookie("token")
  $.ajax({
        //请求方式
        type: "GET",
        //请求的媒体类型
        url: `http://127.0.0.1/api/user/info/${token}`,
        //请求成功
        success(result) {
          if (result == "token is no auth" || result == "UNAUTH") {
            window.location.href = "./login.html"; 
          } else 	$('#email').text(result);
        },
        //请求失败，包含具体的错误信息
        error(e) {
          alert(e.responseText);
        }
      });
    })

function getCookie(objName){//获取指定名称的cookie的值 
    var arrStr = document.cookie.split("; "); 
    for (var i = 0; i < arrStr.length; i++) { 
        var temp = arrStr[i].split("="); 
        if (temp[0] == objName){ 
            return decodeURI(temp[1]); 
        }
    } 
}


</script>



